!function i(o,r,p){function d(e,t){if(!r[e]){if(!o[e]){var a="function"==typeof require&&require;if(!t&&a)return a(e,!0);if(h)return h(e,!0);var s=new Error("Cannot find module '"+e+"'");throw s.code="MODULE_NOT_FOUND",s}var n=r[e]={exports:{}};o[e][0].call(n.exports,function(t){return d(o[e][1][t]||t)},n,n.exports,i,o,r,p)}return r[e].exports}for(var h="function"==typeof require&&require,t=0;tr}(n);if(i)a=s;else{if(s>=t.length)return null;e=s}return p(t,e,a)}for(var a,s=0,n="";s$2',h=/\n/g,g="
",l="@",_=".ps-tagging",u=".ps-tagging-textarea",c=".ps-tagging-wrapper",f=".ps-tagging-beautifier",v=".ps-tagging-hidden",x=".ps-tagging-dropdown",m=".ps-tagging-dropdown-item",w=".active",y=".ps-tagging-loading";function b(t,e){this.textarea=t;this.options=e||{};this.init();return this}return b.prototype.init=function(){this.dom_prepare(),this.textarea.value&&(this.parse_tags(),this.textarea_on_input()),this.$textarea.off(_).on("focus"+_,d.proxy(this.textarea_on_keydown,this)).on("click"+_,d.proxy(this.textarea_on_keydown,this)).on("keydown"+_,d.proxy(this.textarea_on_keydown,this)).on("keyup"+_,d.proxy(this.textarea_on_keyup,this)).on("input"+_,d.proxy(this.textarea_on_input,this)).on("blur"+_,d.proxy(this.textarea_on_blur,this)),this.$dropdown.off(_).on("mouseenter"+_,m,d.proxy(this.dropdown_on_mouseenter,this)).on("mousedown"+_,m,d.proxy(this.dropdown_on_mousedown,this)).on("mouseup"+_,m,d.proxy(this.dropdown_on_mouseup,this))},b.prototype.dom_prepare=function(){this.$textarea=d(this.textarea),this.$textarea.addClass(".ps-tagging-textarea".substr(1)),this.$wrapper=this.$textarea.parent(c),this.$wrapper.length||(this.$textarea.wrap('
'),this.$wrapper=this.$textarea.parent()),this.$beautifier=this.$wrapper.children(f),this.$beautifier.length||(this.$beautifier=d('
'),this.$beautifier.prependTo(this.$wrapper)),this.$hidden=this.$wrapper.children(v),this.$hidden.length||(this.$hidden=d(''),this.$hidden.appendTo(this.$wrapper)),this.$dropdown=this.$wrapper.children(x),this.$dropdown.length||(this.$dropdown=d('
'),this.$dropdown.appendTo(this.$wrapper))},b.prototype.parse_tags=function(){var t,e,a,s,n,i=this.textarea.value;if(this.options.parser&&(t=this.options.parser_groups||{},i=i.replace(this.options.parser,function(){return"@[["+(arguments[t.id]||"")+":user:"+(arguments[t.title]||"")+"]]"})),e=i.match(r),this.textarea.value=i.replace(r,"$2"),this.tags_added=[],e&&e.length)for(n=0;na.start&&this.prev_sel_starta.start&&this.prev_sel_end=this.prev_sel_start&&s<=this.prev_sel_end)&&this.tags_added.splice(h--,1);for(e=this.textarea.selectionStart-this.prev_sel_start-(this.prev_sel_end-this.prev_sel_start),h=0;h=this.prev_sel_start)a.start+=e;else if((s=a.start+a.length)this.prev_sel_start){if(0$1')},b.prototype.hidden_update=s.debounce(function(t,e){var a,s,n,i,o;if(e.length){for(a="^",s="",o=n=0;o=t?this.dropdown_hide():(e=e.substring(a,t),this.dropdown_fetch(e,d.proxy(this.dropdown_update,this)))},200),b.prototype.dropdown_fetch=function(a,s){"function"==typeof this.options.fetcher?this.dropdown_fetching||(this.dropdown_fetching=!0,this.$dropdown.find(y).show(),this.options.fetcher(a,d.proxy(function(t,e){this.$dropdown.find(y).hide(),this.dropdown_fetching=!1,"cache"===e?s(a,t):this.dropdown_toggle()},this))):s(a,[])},b.prototype.dropdown_filter=function(e,t){var a=[];return this.tags_added&&this.tags_added.length&&(a=s.map(this.tags_added,function(t){return""+t.id})),e=e.toLowerCase(),s.filter(t,function(t){return-1===a.indexOf(""+t.id)&&-1',a+='
'+e[s].name+"
",a+="";this.dropdown_show(a)}},b.prototype.dropdown_show=function(t){this.$dropdown.html(t).show(),this.dropdown_is_visible=!0},b.prototype.dropdown_show_more=function(){},b.prototype.dropdown_hide=function(){this.$dropdown.hide(),this.dropdown_is_visible=!1},b.prototype.dropdown_on_mouseenter=function(t){this.dropdown_change_item(t)},b.prototype.dropdown_on_mousedown=function(){this.dropdown_is_clicked=!0},b.prototype.dropdown_on_mouseup=function(t){this.dropdown_select_item(t),this.dropdown_is_clicked=!1,this.dropdown_hide()},b.prototype.dropdown_change_item=function(t){var e,a,s,n=w.substr(1);if("number"!=typeof t)return a=(e=this.dropdown_selected_item=d(t.target)).siblings(w),e.addClass(n),void a.removeClass(n);(e=this.$dropdown.children(w)).length?(s=e[t===i?"prev":"next"](),e.removeClass(n),s.length?(this.dropdown_selected_item=s).addClass(n):this.dropdown_selected_item=!1):(e=this.dropdown_selected_item=this.$dropdown.children()[t===i?"last":"first"]()).addClass(n)},b.prototype.dropdown_select_item=function(t){var e,a,s=t?d(t.currentTarget):this.dropdown_selected_item,n=s.data("id"),i=s.data("name"),o=this.textarea.selectionStart,r=this.textarea.value.substr(0,o).lastIndexOf("@");this.tags_added||(this.tags_added=[]),this.tags_added.push({id:n,name:i,start:r,length:i.length}),e=new RegExp("^([\\s\\S]{"+r+"})[\\s\\S]{"+(o-r)+"}"),a=this.textarea.value.replace(e,"$1"+i)+" ",this.textarea.value=a,this.textarea.setSelectionRange(r+i.length+1,r+i.length+1);var p=this;setTimeout(function(){p.$textarea.trigger("keyup"),p.$textarea.trigger("input")}),this.hidden_update(a,this.tags_added),this.dropdown_hide(),this.$textarea.focus()},b}(i,s,o),i.fn.ps_tagging=function(a,s){return"object"===n(a)&&(s=a),this.each(function(){var t=i(this),e=t.data("ps_tagging");e||(e=new r(this,s),t.data("ps_tagging",e)),"val"===a&&"function"==typeof s?s(e.val()):"reset"===a&&e.reset()})},o.observer.addFilter("peepso_postbox_beautifier",function(t,e){var a=e.data("ps_tagging"),s=e.val(),n=a.tags_added||[];return a.beautifier_update(s,n)},10,2)},{}]},{},[1]);